package com.ymatou.iapi.productmanager.service;

import java.util.List;

import com.google.common.reflect.TypeToken;
import com.ymatou.iapi.productmanager.parameter.BrandDto;
import com.ymatou.iapi.productmanager.parameter.BrandDtoV2;
import com.ymt.base.YmatouBaseCall;
import com.ymt.core.tool.FormatUtil;
import com.ymttest.utils.EnvSetup;
/**
*获取用户公共品牌信息Call
*FreeMaker Template自动生成代码
*/
public class GetCommonBrandsForUserCall extends YmatouBaseCall{
	private static String opurl ="api/Brand/GetCommonBrandsForUser";
	
	public GetCommonBrandsForUserCall() {
		super(EnvSetup.getSystemUrl("productmanager"),opurl,"GET","PARAM");
	}
	@Override
	public void addDefHeader() {
		client.addHeader("Accept","text/xml,text/javascript,text/html,application/json");
		client.addHeader("Content-Type", "application/json; charset=UTF-8");
	}
	
	public List<BrandDtoV2> getBrands(){
		String sBrands=getJsonObject().get("Data").getAsJsonObject().get("Brands").getAsJsonArray().toString();
		List<BrandDtoV2> Brands=(List<BrandDtoV2>)FormatUtil.GSONToObject(sBrands, new TypeToken<List<BrandDtoV2>>(){}.getType());
		return Brands;
	}
}